[tsp-client] Fix error reported when the typespec project dir doesnt exist in cloned repo#13460
Merged
catalinaperalta merged 2 commits intomainfrom Feb 7, 2026
Merged
[tsp-client] Fix error reported when the typespec project dir doesnt exist in cloned repo#13460catalinaperalta merged 2 commits intomainfrom
catalinaperalta merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error handling and messaging when the TypeSpec project directory doesn't exist in a cloned repository at a specified commit. Previously, users would see a confusing raw ENOENT error; now they receive clear guidance about verifying their tsp-location.yaml configuration.
Changes:
- Enhanced error messages in git operations to provide clearer context when git commands fail
- Added validation to check if the TypeSpec project directory exists after cloning and checkout, with a helpful error message directing users to verify their configuration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/tsp-client/src/git.ts | Wrapped git operation errors with descriptive messages for getRepoRoot, cloneRepo, and checkoutCommit functions |
| tools/tsp-client/src/commands.ts | Added validation using stat to check if the cloned TypeSpec project directory exists, with a user-friendly error message and cleanup on failure |
Comments suppressed due to low confidence (1)
tools/tsp-client/src/commands.ts:398
- The validation added for the main TypeSpec project directory should also be applied to additional directories. After checking out the commit, the code copies additional directories from the cloned repository (lines 393-398), but doesn't verify they exist first. This could result in the same confusing ENOENT error that this PR aims to fix, but for additional directories instead of the main project directory. Consider adding similar existence checks for each additional directory before attempting to copy them.
for (const dir of tspLocation.additionalDirectories!) {
Logger.info(`Syncing additional directory: ${dir}`);
await cp(joinPaths(cloneDir, dir), joinPaths(tempRoot, getAdditionalDirectoryName(dir)), {
recursive: true,
});
}
timotheeguerin
approved these changes
Feb 6, 2026
Member
Author
|
/check-enforcer evaluate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13413
This happens when there is a valid commit, but that commit doesn't contain the typespec project, so the entire sparse checkout process including the commit checkout pass, but when tsp-client attempts to look for the typespec project directory it doesnt exist for that specific commit. Users would have to verify that they configured the right project directory and commit in tsp-location.yaml.